package com.app.entity;

import lombok.Data;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 商品
 *
 * @autor xiaoyu.fang
 * @date 2019/10/10 11:14
 */
@Data
@Document(collection = "s_goods")
@CompoundIndex(def = "{'type':1, 'title':1, 'createAt':-1}", background = true, name = "s_goods_index")
public class Goods implements Serializable {
    @Id
    private ObjectId id;
    /**
     * 类型
     *
     * @since com.app.common.enums.GoodsTypeEnum
     */
    @NotNull(message = "类型不能为空", groups = {Create.class})
    private Integer type;
    /**
     * 标题
     */
    private String title;
    /**
     * 说明
     */
    private String explain;
    /**
     * 原价
     * 单位：分
     */
    private String originalPrice;
    /**
     * 现价
     * 单位：分
     */
    private String price;
    /**
     * 存货量
     */
    private Long inventory;
    /**
     * 收藏量
     */
    private Long collection;
    /**
     * 图片
     */
    private String image;
    /**
     * 图片集合
     */
    private List<String> pictures;
    /**
     * 标签
     */
    private List<String> tags;
    /**
     * 创建时间
     */
    private Date createAt;
    /**
     * 数据状态
     */
    private Integer dataStatus;

    public interface Create{}
}
